package com.ra.landlord;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Transient;

import com.googlecode.cswish.annotation.cm;

@Entity
public class RoomConfig {

	private Integer id;

	@cm("床")
	private Boolean bed;
	
	@cm("阳台")
	private Boolean balcony;
	
	@cm("热水器")
	private Boolean heater;
	
	@cm("燃气灶")
	private Boolean gas;
	
	@cm("宽带")
	private Boolean broadband;
	
	@cm("冰箱")
	private Boolean freezer;
	
	@cm("空调")
	private Boolean airCondition;
	
	@cm("电视")
	private Boolean tv;
	
	@cm("洗衣机")
	private Boolean washingMachine;
	
	@cm("桌椅")
	private Boolean desk;
	
	@cm("衣柜")
	private Boolean armoire;
	
	@cm("洗手间")
	private Boolean toilet;
	
	@cm("厨房")
	private Boolean kitchen;
	
	@cm("电梯")
	private Boolean elevator;
	
	public RoomConfig()
	{
		this.bed = false;
		this.balcony = false;
		this.heater = false;
		this.gas = false;
		this.broadband = false;
		this.freezer = false;
		this.airCondition = false;
		this.tv = false;
		this.washingMachine = false;
		this.desk = false;
		this.armoire = false;
		this.toilet = false;
		this.kitchen = false;
		this.elevator = false;
	}

	@Id
	@GeneratedValue
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Boolean getBed() {
		return bed;
	}

	public void setBed(Boolean bed) {
		this.bed = bed;
	}

	public Boolean getBalcony() {
		return balcony;
	}

	public void setBalcony(Boolean balcony) {
		this.balcony = balcony;
	}

	public Boolean getHeater() {
		return heater;
	}

	public void setHeater(Boolean heater) {
		this.heater = heater;
	}

	public Boolean getGas() {
		return gas;
	}

	public void setGas(Boolean gas) {
		this.gas = gas;
	}

	public Boolean getBroadband() {
		return broadband;
	}

	public void setBroadband(Boolean broadband) {
		this.broadband = broadband;
	}

	public Boolean getFreezer() {
		return freezer;
	}

	public void setFreezer(Boolean freezer) {
		this.freezer = freezer;
	}

	public Boolean getAirCondition() {
		return airCondition;
	}

	public void setAirCondition(Boolean airCondition) {
		this.airCondition = airCondition;
	}

	public Boolean getTv() {
		return tv;
	}

	public void setTv(Boolean tv) {
		this.tv = tv;
	}

	public Boolean getWashingMachine() {
		return washingMachine;
	}

	public void setWashingMachine(Boolean washingMachine) {
		this.washingMachine = washingMachine;
	}

	public Boolean getDesk() {
		return desk;
	}

	public void setDesk(Boolean desk) {
		this.desk = desk;
	}

	public Boolean getArmoire() {
		return armoire;
	}

	public void setArmoire(Boolean armoire) {
		this.armoire = armoire;
	}

	public Boolean getToilet() {
		return toilet;
	}

	public void setToilet(Boolean toilet) {
		this.toilet = toilet;
	}

	public Boolean getKitchen() {
		return kitchen;
	}

	public void setKitchen(Boolean kitchen) {
		this.kitchen = kitchen;
	}

	public Boolean getElevator() {
		return elevator;
	}

	public void setElevator(Boolean elevator) {
		this.elevator = elevator;
	}
	
	@Transient
	public String getDisplayString()
	{
		StringBuilder desc = new StringBuilder();
		
		setStringByValue(desc, this.getBed(), "床");
		setStringByValue(desc, this.getBalcony(), "阳台");
		setStringByValue(desc, this.getHeater(), "热水器");
		setStringByValue(desc, this.getGas(), "燃气灶");
		setStringByValue(desc, this.getBroadband(), "宽带");
		setStringByValue(desc, this.getFreezer(), "冰箱");
		setStringByValue(desc, this.getAirCondition(), "空调");
		setStringByValue(desc, this.getTv(), "电视");
		setStringByValue(desc, this.getWashingMachine(), "洗衣机");
		setStringByValue(desc, this.getDesk(), "桌椅");
		setStringByValue(desc, this.getArmoire(), "衣柜");
		setStringByValue(desc, this.getToilet(), "洗手间");
		setStringByValue(desc, this.getKitchen(), "厨房");
		setStringByValue(desc, this.getElevator(), "电梯");
		
		return desc.toString();
	}
	
	@Transient
	public void clearValues()
	{
		this.setBed(false);
		this.setBalcony(false);
		this.setHeater(false);
		this.setGas(false);
		this.setBroadband(false);
		this.setFreezer(false);
		this.setAirCondition(false);
		this.setTv(false);
		this.setWashingMachine(false);
		this.setDesk(false);
		this.setArmoire(false);
		this.setToilet(false);
		this.setKitchen(false);
		this.setElevator(false);
	}
	
	@Transient
	private void setStringByValue(StringBuilder desc, Boolean value, String displayV)
	{
		if (Boolean.TRUE.equals(value))
		{
			if (desc.length() > 0)
			{
				desc.append("、").append(displayV);
			}
			else
			{
				desc.append(displayV);
			}
		}
	}
}
